#ifndef I_PACKAGE_CODEC_H
#define I_PACKAGE_CODEC_H

#include <boost/shared_ptr.hpp>
#include "scope_array.h"
#include "i_io_handler.h"

class IPackageCodec
{
public:
	typedef boost::shared_ptr<IPackageCodec> Ptr;
	virtual void process(const scoped_array<char>& src, scoped_array<char>& dest) = 0;
};

class DuplexCodec : public IIoAttachment
{
	IPackageCodec::Ptr out_;
	IPackageCodec::Ptr in_;
public:
	typedef boost::shared_ptr<DuplexCodec> Ptr;

	inline void processOut(const scoped_array<char>& src, scoped_array<char>& dest)
	{
		out_->process(src, dest);
	}

	inline void processIn(const scoped_array<char>& src, scoped_array<char>& dest)
	{
		in_->process(src, dest);
	}

	DuplexCodec(IPackageCodec::Ptr out, IPackageCodec::Ptr in) : out_(out), in_(in){}
};

#endif